var line = doc.getLine(pos.line);
var leadLength = 0;
var prefixChar = '';
var whitespace = false;
for (var i = pos.ch-1; i >=0; i--) {
var ch = line[i];
if (!whitespace && this._isIdentifierChar(ch)) {
leadLength++; continue;}
whitespace = /\s/.test(ch);
if (!whitespace) {
prefixChar = ch;
break;}
}
var tailLength = 0;
var suffixChar = '';
whitespace = false;
for (var i = pos.ch; i <line.length; i++) {
var ch = line[i];
if (!whitespace && this._isIdentifierChar(ch)) {
tailLength++; continue;}
whitespace = /\s/.test(ch);
if (!whitespace) {
suffixChar = ch;
break;}
}
return {pos: pos,
offset: offset,
line: line,
leadLength: leadLength,
prefixChar: prefixChar,
tailLength: tailLength,
suffixChar: suffixChar
};
}
/** More specifially, number or identifier (numbers, letters, underscore and dollar). */private _isIdentifierChar(ch: string): boolean {
if (ch.toLowerCase()!==ch.toUpperCase())
return true;
else if (ch==='_' || ch==='$')
return true;
else if (ch>='0' && ch<='9')
return true;
elsereturn false;
}
private _initEditor() {
var options = this._shared.options || CodeMirrorEditor.standardEditorConfiguration();
this._shared.cm = new CodeMirror(
(element) => this._shared.element = element,
options);this._shared.cm.getWrapperElement().style.fontSize = '16px';
}
private _initDoc() {
// resolve options (allow override)var options = this._shared.options || CodeMirrorEditor.standardEditorConfiguration();
this._doc =
options.mode ? new CodeMirror.Doc('', options.mode) :
new CodeMirror.Doc('');
this._positionOnOpen = true;
// invoke overridable handleLoad()